package com.hackerrank.contests.july13.challenges.pegsolitaire;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution {
	private static final int LEFT = 0, RIGHT = 1, UP = 2, DOWN = 3;
	private static long st = 0;
	private static class Move {
		int r, c, d;
		public Move(int r, int c, int d) {
			this.r = r;
			this.c = c;
			this.d = d;
		}
		public String toString() {
			StringBuilder sb = new StringBuilder().append(c).append(" ").append(r).append(" ");
			switch(d) {
			case LEFT:
				sb.append("LEFT");
				break;
			case RIGHT:
				sb.append("RIGHT");
				break;
			case UP:
				sb.append("UP");
				break;
			case DOWN:
				sb.append("DOWN");
				break;
			}
			return sb.toString();
		}
	}
	private static List<Move> cm = new ArrayList<Move>(), bm = new ArrayList<Move>(cm);
	private static int ic = 0;
	private static boolean solve(char[][] b) {
		if(System.currentTimeMillis() - st >= 4500)
			return true;
		boolean f = false;
		for(int r = 0; r < b.length; r++) {
			for(int c = 0; c < b[r].length; c++) {
				if(b[r][c] == '.') {
					if(c >= 2 && b[r][c - 1] == '.' && b[r][c - 2] == '-') {
						f = true;
						b[r][c] = '-';
						b[r][c - 1] = '-';
						b[r][c - 2] = '.';
						Move m = new Move(r, c, LEFT);
						cm.add(m);
						if(solve(b))
							return true;
						cm.remove(cm.size() - 1);
						b[r][c] = '.';
						b[r][c - 1] = '.';
						b[r][c - 2] = '-';
					}
					if(c < b[r].length - 2 && b[r][c + 1] == '.' && b[r][c + 2] == '-') {
						f = true;
						b[r][c] = '-';
						b[r][c + 1] = '-';
						b[r][c + 2] = '.';
						Move m = new Move(r, c, RIGHT);
						cm.add(m);
						if(solve(b))
							return true;
						cm.remove(cm.size() - 1);
						b[r][c] = '.';
						b[r][c + 1] = '.';
						b[r][c + 2] = '-';
					}
					if(r >= 2 && b[r - 1][c] == '.' && b[r - 2][c] == '-') {
						f = true;
						b[r][c] = '-';
						b[r - 1][c] = '-';
						b[r - 2][c] = '.';
						Move m = new Move(r, c, UP);
						cm.add(m);
						if(solve(b))
							return true;
						cm.remove(cm.size() - 1);
						b[r][c] = '.';
						b[r - 1][c] = '.';
						b[r - 2][c] = '-';
					}
					if(r < b.length - 2 && b[r + 1][c] == '.' && b[r + 2][c] == '-') {
						f = true;
						b[r][c] = '-';
						b[r + 1][c] = '-';
						b[r + 2][c] = '.';
						Move m = new Move(r, c, DOWN);
						cm.add(m);
						if(solve(b))
							return true;
						cm.remove(cm.size() - 1);
						b[r][c] = '.';
						b[r + 1][c] = '.';
						b[r + 2][c] = '-';
					}
				}
			}
		}
		if(!f && cm.size() > bm.size()) {
			bm = new ArrayList<Move>(cm);
			if(bm.size() == ic - 1)
				return true;
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int M = in.nextInt(), N = in.nextInt();
		in.nextLine();
		char[][] b = new char[M][N];
		for(int r = 0; r < M; r++) {
			b[r] = in.nextLine().toCharArray();
			for(int c = 0; c < N; c++)
				if(b[r][c] == '.')
					ic++;
		}
		st = System.currentTimeMillis();
		solve(b);
		System.out.println(bm.size());
		for(int i = 0; i < bm.size(); i++)
			System.out.println(bm.get(i));
	}
}
